@extends('base')

@section('content')
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form" action="{!! route('caiwu.order') !!}">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="" class="layui-form-label">订单编号：</label>
                        <div class="layui-input-block" style="width: 275px">
                            <input type="text" name="num" placeholder="请输入编号" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" lay-submit lay-filter="search" class="layui-btn layui-btn-sm" >搜索</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-card-body">
            <table id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['layer','table','form','laydate','dropdown'],function () {
            var $ = layui.jquery;
            var dropdown = layui.dropdown
            var layer = layui.layer;
            var form = layui.form;
            var table = layui.table;
            var laydate = layui.laydate;
            //用户表格初始化
            var dataTable = table.render({
                elem: '#dataTable'
                ,height: 'full'
                ,url: "{!! route('caiwu.order') !!}" //数据接口
                ,page: true //开启分页
                ,cols: [[ //表头
                    {field: 'num', title: '订单编号'}
                    ,{field: 'stime', title: '开始日期'}
                    ,{field: 'etime', title: '结束日期'}
                    ,{field: 'total_money', title: '总金额'}
                    ,{field: 'payed_money', title: '已收款'}
                    ,{field: 'remark', title: '备注'}
                    ,{field: 'check_status', title: '审核状态',templet:function (d) {
                            if (d.check_status===1){
                                return '<span class="layui-badge" lay-event="check">待审核</span>'
                            }else if (d.check_status===2){
                                return '<span class="layui-badge layui-bg-black" lay-event="check">未通过</span>'
                            }else if (d.check_status===3){
                                return '<span class="layui-badge layui-bg-green" lay-event="check">通过</span>'
                            }
                        },width: 100}
                    ,{field: 'check_result', title: '审核备注'}
                    ,{field: 'created_at', title: '录入时间'}
                ]]
            });

            table.on('row(dataTable)', function(obj){
                var parent$ = window.parent.layui.jquery;
                parent$("#order_tips").text("订单编号："+obj.data.num)
                parent$("#order_id").val(obj.data.id)
                parent.layer.closeAll()
            });

        })
    </script>
@endsection
